home *** CD-ROM | disk | FTP | other *** search
- From: jamie@pro-net.co.uk (James Dickson)
- Newsgroups: comp.lang.c
- Subject: Re: Pointer to Functions and Calls thereof??
- Date: Fri, 19 Apr 1996 10:07:20 GMT
- Message-ID: <31776500.1903078@news.globalnet.co.uk>
- References: <Dq01Ft.Dqn@latcs1.lat.oz.au>
- X-Newsreader: Forte Agent .99d/32.182
- NNTP-Posting-Host: client8114.globalnet.co.uk
- Path: news.globalnet.co.uk!
-
- On Wed, 17 Apr 1996 09:09:28 GMT, woelkerl@lion.cs.latrobe.edu.au
- (Eric Woelkerling) wrote:
-
- > Hi! Can anybody fill me in as to how to get a pointer to a function
- >and then use this to do the call?? I have a situation where a particular function
- >will be selected from a set of functions and used throughout my entire code,
- >but the function selected will depend on the runtime selection by thge user..
- >
- >so far.. I have got as far as..
- >
- >
- > void func1(void){naughty bits}
- > void func2(void){naughty bits}
- >
- > void main(void)
- > { void *a[1];
- >
- > a[1]=func1;
- > a[2]=func2;
- >
- > (*a[1])();
- > }
- >
- > Is there something obvious I am missing here?? I am on a PC and using
- >borland c++ compiler...
- >
- > If you can help, please mail me directly Thanks!
- >
- > Eric Woelkerling
- > woelkerl@lion.lat.oz.au
- >
-
- Eric,
-
- I think your declaration for 'a' should be:
-
- void (*a[2])();
-
-
- Try it and let me know.
-
-
- James Dickson.
-